package engine.dojo.element;

import org.json.JSONException;
import org.json.JSONObject;
import org.jsoup.nodes.Element;

public class ListItemManager {
	
	public static JSONObject specializeListItem(JSONObject element){
		
		JSONObject returnAttributes = null;
		JSONObject elementAttributes = null;
		
		try{
			elementAttributes = element.getJSONObject("attributes");
		
			if(elementAttributes.getString("itemType").equals("custom")){
					
				JSONObject attributes = new JSONObject();
				returnAttributes = new JSONObject();
				
				String label = elementAttributes.getString("label");
				String wsURL = elementAttributes.getString("wsURL");
				String wsSource = elementAttributes.getString("wsSource");
				
				attributes.put("postCreate", "listItemCustomClick('"+element.getString("id")+"');");
				attributes.put("label", label);
				attributes.put("rightText", "Seleziona "+label);
				attributes.put("clickable", "true");
				attributes.put("wsURL", wsURL);
				attributes.put("wsSource", wsSource);
				
				returnAttributes.put("attributes", attributes);
				
			}else if(elementAttributes.getString("itemType").equals("entity")){
				
			}
			
		}catch(JSONException e){
			e.printStackTrace();
		}
		
		return returnAttributes;
	}

}
